// SETUP

#include endepisodegraphics_jester.txt

// HELPER FUNCTIONS	

function signanimate(sign) {
	var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.show("loop");
}

function spinthewheel(sign, wheel) {
  var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.hide();
	
  wheel.x = 30;
  wheel.y = -30;
  play("spinthewheel");
	var s = wheel.show("spin1");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	wheel.hide();
}

// ACTORS

actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
actor("Witch", 150, screenheight - 100, 0xb496ec, LEFT, BOTTOM, "chat_witch", "characters/witch/charicon_witch");
// INTRO

play("music_cutscene_lesscheery");

changebackground("intro_sign");

sign.y = -screenheight;
jester.y = -screenheight;
sign.show("loop");
jester.show("idle");

Actuate.tween(sign, 2, { y: 0 }).ease(Expo.easeOut);
Actuate.tween(jester, 2, { y: 0 }).ease(Expo.easeOut);

wait(0.5);

fadein();

wait(1.5);

jester.show("talking");
actor("Jester", screenwidthmid + 200, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "What a fight! You were amazing!");
jester.show("idle");

speak("Witch", "Honestly, I just lost myself in the moment.");
speak("Witch", "I forgot I was even on camera - it was all about the|spells and the dice. What a wonderful experience!");

jester.show("talking");
actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "Shall we find out whether|you’ve won a prize?");
jester.show("idle");

speak("Witch", "I mean it’s not really about the prize, is it?");
speak("Witch", "But also, yes.");

jester.show("talking");
actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "Time to SPIN THE WHEEL!|SPIN THE WHEEL!");
speak("Jester", "If it lands on the PRIZE, then|you get your heart’s desire!");
speak("Jester", "More social media followers, I think?");
jester.show("idle");

speak("Witch", "That’s right! SPIN THE WHEEL! SPIN THE WHEEL!");

jester.hide();

spinthewheel(sign, wheel);

signanimate(sign);

jester.show("talking");
actor("Jester", screenwidthmid + 400, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "And ohhhh... bad luck - it|looks like that’s a no!");
actor("Jester", screenwidthmid, 100, Col.multiplylightness(Col.RED, 1.25), LEFT, TOP, "chat_jester", "characters/misc/charicon_humanjester");
speak("Jester", "But don’t you worry - you’ve made it through to|the next episode, and another chance to win.");
jester.show("idle");

gamecompletefromcutscene();
